﻿using System.Diagnostics;
using NExplorer.AddIns.WinRar.Properties;

namespace NExplorer.AddIns.WinRar
{
	internal class ExtractFilesCommand : CommandBase
	{
		public ExtractFilesCommand()
			: base("Extract files...")
		{}

		public override void Execute()
		{
			if (WinRarUtility.ConfirmWinRarAvailable())
			{
				// WinRAR  <command> -<switch1> -<switchN> <archive> <files...> <@listfiles...> <path_to_extract\>

				// Command 
				if (ServiceManager.Explorer.SelectedItems.Count == 1)
				{
					ProcessStartInfo startInfo = new ProcessStartInfo(Settings.Default.WinRarFullPath);
					startInfo.Arguments = string.Format("X \"{0}\"", ServiceManager.Explorer.SelectedItems[0].FullName);

					Process.Start(startInfo);
				}
			}
		}
	}
}
